<template>
	<view id="orderPay">
		<Header txt="续费" v-if="baidu"></Header>
		<HeaderB txt="续费" v-if="!baidu"></HeaderB>
		<view class="item">
			<text class="title">订单号</text>
			<view class="iblock">
				<view class="content">
					{{order.orderNo}}
				</view>
			</view>			
		</view>
		<view class="item"  v-if="
		  order.type == 3 ||
		  order.type == 5 ||
		  order.type == 8 ||
		  order.type == 9 ||
		  order.type == 12 ||
		  order.type == 7 ||
		  order.type == 6            
		">
			<text class="title">套餐时长：</text>
			<view class="iblock">
				<view class="content" @click="useOutClickSide">
				    <easy-select ref="easySelect" size="medium" :value="selecValue3" 
					:options='[{value:1,label:"包天"},{value:30,label:"包月"},{value:180,label:"包半年"},{value:365,label:"包年"}]' @selectOne="selectOne3">
					</easy-select>
				</view>
			</view>			
		</view>
		<view class="item" v-if="order.type == 14">
			<text class="title">选择时间：</text>
			<view class="iblock">
				<view class="content" @click="useOutClickSide">
				    <easy-select ref="easySelect" size="medium" :value="selecValue7" 
					:options='[{value:7,label:"包周"},{value:30,label:"包月"},{value:180,label:"包半年"},{value:365,label:"包年"}]' @selectOne="selectOne7">
					</easy-select>
				</view>
			</view>			
		</view>
		<view class="item">
			<text class="title">优惠券：</text>
			<view class="iblock">
				<view class="content" @click="useOutClickSide">
				    <easy-select ref="easySelect" size="medium" :value="selecValue4" 
					:options='couponList' @selectOne="selectOne4">
					</easy-select>
				</view>
			</view>			
		</view>
		<view class="item" v-if="
			(order.type == 15 && order.poolType == 1) ||
            (order.type == 15 && order.poolType == 2) ||
            (order.type == 15 && order.poolType == 3)"
			>
			<text class="title" >提取数量：</text>
			<view class="iblock">
				<view class="block">
					<view class="block reduce" @click="reduce(1,1000,1000000)">-</view>
					<view class="block">
						<input type="number" value="" v-model="multiple1" @input="inputN(1)"/>
					</view>
					<view class="block add" @click="add(1,1000,1000000)">+</view>
				</view>
			</view>
		</view>
		<view class="item" v-if="
			(order.type == 15 && order.poolType == 4) ||
		    (order.type == 15 && order.poolType == 5) ||
		    (order.type == 15 && order.poolType == 6)"
			>
			<text class="title" >提取数量：</text>
			<view class="iblock">
				<view class="block">
					<view class="block reduce" @click="reduce(15,100,1000000)">-</view>
					<view class="block">
						<input type="number" value="" v-model="multiple15" @input="inputN(15)"/>
					</view>
					<view class="block add" @click="add(15,100,1000000)">+</view>
				</view>
			</view>
		</view>
		<view class="item" v-if="order.type == 4">
			<text class="title" >转发数量：</text>
			<view class="iblock">
				<view class="block">
					<view class="block reduce" @click="reduce(2,100000,100000000)">-</view>
					<view class="block">
						<input type="number" value="" v-model="multiple2" @input="inputN(2)"/>
					</view>
					<view class="block add" @click="add(2,100000,100000000)">+</view>
				</view>
			</view>
		</view>
		<view class="item" v-if="order.type == 11 && hoursM == 1">
			<text class="title" >购买总数：</text>
			<view class="iblock">
				<view class="block">
					<view class="block reduce" @click="reduce(3,1000,1000000)">-</view>
					<view class="block">
						<input type="number" value="" v-model="multiple3" @input="inputN(3)"/>
					</view>
					<view class="block add" @click="add(3,1000,1000000)">+</view>
				</view>
			</view>
		</view>
		<view class="item" v-if="order.type == 11 && hoursM == 2">
			<text class="title" >购买总数：</text>
			<view class="iblock">
				<view class="block">
					<view class="block reduce" @click="reduce(4,100,1000000)">-</view>
					<view class="block">
						<input type="number" value="" v-model="multiple4" @input="inputN(4)"/>
					</view>
					<view class="block add" @click="add(4,100,1000000)">+</view>
				</view>
			</view>
		</view>
		<view class="item"  v-if="
		  (order.type == 3 && order.poolType == 1 && day == 1) ||
		   (order.type == 3 && order.poolType == 2 && day == 1) ||
		   (order.type == 3 && order.poolType == 3 && day == 1) ||
		   (order.type == 5 && day == 1) ||
		   (order.type == 7 && day == 1) ||
		   (order.type == 12 && day == 1)           
		" >
			<text class="title">购买天数：</text>
			<view class="iblock">
				<view class="block reduce" @click="reduce(13,1,29)">-</view>
				<view class="block">
					<input type="number" value="" v-model="dayvalue" @input="inputN(13,29)"/>
				</view>
				<view class="block add" @click="add(13,1,29)">+</view>
			</view>
		</view>
		<view class="item">
			<text class="title">账单合计：</text>
			<view class="iblock">
				<text>¥{{money + "元"}}</text>
			</view>			
		</view>
		<view class="part2">
			<view class="">
				<view class="active" @click="change(5)" v-if="alipay==true">
					<image  src="https://iconimg.oss-cn-hangzhou.aliyuncs.com/%E7%86%8A%E7%8C%AB%E4%BB%A3%E7%90%86/%E5%9B%BE%E6%A0%87/zhifubao.png" mode="aspectFit"></image>
					<text>支付宝支付</text>
					<radio class="im" value="5" :checked="payType==5" color="#007AFF" />
				</view>
				<view class="active" @click="change(6)" v-if="weixin==true">
					<image  src="https://iconimg.oss-cn-hangzhou.aliyuncs.com/%E7%86%8A%E7%8C%AB%E4%BB%A3%E7%90%86/%E5%9B%BE%E6%A0%87/weixin.png" mode="aspectFit"></image>
					<text >微信支付</text>
					<radio class="im" value="6" :checked="payType==6" color="#007AFF" />
				</view>			
				<view class="active" @click="change(3)">
					<image  src="../../static/usercenter/wallet.png" mode="aspectFit"></image>
					<text >钱包支付（余额:{{nmoney}}）</text>
					<radio class="im" value="6" :checked="payType==3" color="#007AFF" />
				</view>
			</view>
		</view>
		<view class="prompt_text2">
			* 使用钱包支付时不可使用优惠券
		</view>
		<view class="btn">
			<button type="primary" @click="submit2">支付</button>
		</view>
		<view class="btn" v-if="!baidu">
			<button type="primary" @click="submit3">其他方式支付</button>
		</view>
	</view>	
</template>
<script>
	import formatDate2  from  "../../common/com.js"
	export default {
		data() {
			return {
				orderNo:'',
				selecValue4:'',
				money:'',
				day: 1,
				multiple1: 3000,
				multiple2: 100000,
				multiple3: 1000,
				multiple4: 100,
				multiple15: 100,
				times: 5,
				payType: 5,
				money: 0,
				show1: false,
				hoursM: 1,
				day14: 7,
				coupon: 0,
				couponDis: false,
				couponList: [{ label: "不使用优惠", value: 0 }],
				dayvalue: 1,
				weixin:true,
				alipay:true,
				selecValue7:'包周',
				selecValue3:'包天',
				baidu:true
			}
		},
		computed:{
			async setMoney() {
			      let that = this;
			      let payMoney = 0;
			      let tar = 0;
			      if (this.coupon != 0 && this.couponList.length > 1) {
			        this.couponList.forEach((item) => {
			          if (item.value == this.coupon) {
			            tar = item.label.substring(0, item.label.indexOf("元"));
			            return false;
			          }
			        });
			      }
			      let _data = {};
			      if (this.order.type == 1) {
			        _data = {
			          orderNo: this.order.orderNo,
			          day: 0,
			          times: this.multiple1 / 1000,
			        };
			      }
			      if (this.order.type == 2) {
			        _data = { orderNo: this.order.orderNo, day: this.day, times: 0 };
			      }
			      if (this.order.type == 3) {
			        console.log(this.day)
			        if (this.day == 1) {
			          _data = { orderNo: this.order.orderNo, day: this.dayvalue, times: 0 };
			        } else {
			          _data = { orderNo: this.order.orderNo, day: this.day, times: 0 };
			        }
			      }
			      if (this.order.type == 4) {
			        _data = {
			          orderNo: this.order.orderNo,
			          day: 0,
			          times: this.multiple2 / 100000,
			        };
			      }
			      if (this.order.type == 5) {
			        if (this.day == 1) {
			          _data = { orderNo: this.order.orderNo, day: this.dayvalue, times: 0 };
			        } else {
			          _data = { orderNo: this.order.orderNo, day: this.day, times: 0 };
			        }
			      }
			      if (this.order.type == 8) {
			        _data = { orderNo: this.order.orderNo, day: this.day, times: 0 };
			      }
			      if (this.order.type == 9) {
			        _data = { orderNo: this.order.orderNo, day: this.day, times: 0 };
			      }
			      if (this.order.type == 11) {
			        if (this.hoursM == 2) {
			          _data = {
			            orderNo: this.order.orderNo,
			            day: 0,
			            times: that.multiple4 / 100,
			          };
			        } else {
			          _data = {
			            orderNo: this.order.orderNo,
			            day: 0,
			            times: that.multiple3 / 100,
			          };
			        }
			      }
			      if (this.order.type == 7) {
			        if (this.day == 1) {
			          _data = { orderNo: this.order.orderNo, day: this.dayvalue, times: 0 };
			        } else {
			          _data = { orderNo: this.order.orderNo, day: this.day, times: 0 };
			        }
			      }
			      if (this.order.type == 12) {
			        if (this.day == 1) {
			          _data = { orderNo: this.order.orderNo, day: this.dayvalue, times: 0 };
			        } else {
			          _data = { orderNo: this.order.orderNo, day: this.day, times: 0 };
			        }
			      }
			      if (this.order.type == 6) {
			        _data = {
			          day: this.day,
			          orderNo: this.order.orderNo,
			          times: 0,
			        };
			      }
			      if (this.order.type == 14) {
			        _data = { orderNo: this.order.orderNo, day: this.day14, times: 0 };
			      }
			      if (
			        (this.order.type == 15 && this.order.poolType == 1) ||
			        (this.order.type == 15 && this.order.poolType == 2) ||
			        (this.order.type == 15 && this.order.poolType == 3)
			      ) {
			        _data = { orderNo: this.order.orderNo, day: 0, times: this.multiple1 / 1000 };
			      }
			      if (
			        (this.order.type == 15 && this.order.poolType == 4) ||
			        (this.order.type == 15 && this.order.poolType == 5) ||
			        (this.order.type == 15 && this.order.poolType == 6)
			      ) {
			        _data = { orderNo: this.order.orderNo, day: 0, times: this.multiple15 / 100 };
			      }
			      await this.$store
			      	   .dispatch("Caculate",_data)
			      	   .then((response) => {
			      		if (response.data.code == "0") {
			      		  payMoney = response.data.obj-tar;
			      		  this.money = payMoney;
			      		  if( this.money <0){
			      			   this.money =0
			      		  }
			      		  
			      		}	
			      	})		
					payMoney=this.money;		
			      return payMoney;
			    },
			userInfo() {
			  return this.$store.state.userInfo;
			},
			price() {
			  return this.$store.state.price;
			},
			order() {
			  return this.$store.state.orderPay;
			},
			nmoney() {
			  return this.$store.state.leftMoney;
			},	    
		},
		onLoad(){
			this.getlistUseableCoupon();
			// #ifdef MP-WEIXIN
			this.weixin=true
			this.alipay=false
			this.payType=6
			// #endif
			// #ifdef  MP-ALIPAY
			this.weixin=false
			this.alipay=true
			// #endif 
			// #ifdef MP-BAIDU
			this.weixin=false
			this.alipay=false
			this.payType=3
			this.baidu=false
			// #endif
		},
		watch: {
		   day() {
		     this.getlistUseableCoupon();
		   },
		   day14() {
		     this.getlistUseableCoupon();
		   },
		   multiple1() {
		     this.getlistUseableCoupon();
		   },
		   multiple15() {
		     this.getlistUseableCoupon();
		   },
		   multiple2() {
		     this.getlistUseableCoupon();
		   },
		   multiple3() {
		     this.getlistUseableCoupon();
		   },
		   multiple4() {
		     this.getlistUseableCoupon();
		   },
		   coupon: function (newVal) {
		     this.getlistUseableCoupon();
		   },
		   dayvalue: function (newVal) {
		     this.getlistUseableCoupon();
		   },
		   'payType': function (newVal) {
		     if (newVal == "3") {
		       this.couponDis = true;
		       this.coupon = "0";
				this.selecValue4="不使用优惠"
		     	this.couponList=[{ label: "不使用优惠", value: 0 }]			
		     }else {
		       this.couponDis = false;
				this.getlistUseableCoupon()
		     }
		   },
		 },   
		methods: {
			selectOne3(options) {
			    this.selecValue3 =options.label
				this.day=options.value
			},
			selectOne7(options) {
			    this.selecValue7 =options.label
				this.day14=options.value
			},
			change(num){
				this.payType=num
			},
			formatDate2(str, type){
				    var oDate = new Date(str),
				        oYear = oDate.getFullYear(),
				        oMonth = oDate.getMonth() + 1,
				        oDay = oDate.getDate(),
				        oHour = oDate.getHours();
				    var oMin = oDate.getMinutes(),
				        oSen = oDate.getSeconds();
				    oMonth = oMonth >= 10 ? oMonth : '0' + oMonth;
				    // oDay = oDay >= 10 ? oDay : '0'+oDay;
				    oHour = oHour >= 10 ? oHour : '0' + oHour;
				    oMin = oMin >= 10 ? oMin : '0' + oMin;
				    oDay = oDay >= 10 ? oDay : '0' + oDay;
				    oSen = oSen >= 10 ? oSen : '0' + oSen;
				    var oTime = oYear + '-' + oMonth + '-' + oDay; // 最后拼接时间
				    if (type && type == 2) {
				        return oYear + '-' + oMonth + '-' + oDay + ' ' + oHour + ':' + oMin
				    }
				    return oTime;
				},
			useOutClickSide(){
				this.$refs.easySelect.hideOptions && this.$refs.easySelect.hideOptions()
			},
			selectOne4(options){
				this.selecValue4 =options.label
				this.coupon=options.value
			},
			getlistUseableCoupon() {
			      let that = this;
			      that.setMoney
			        .then(function (result) {
			          let _data = { limitMoney: result, usedType: 0 };
			          // 按量
			          if (that.showItem == 1 && that.form1.type == 1) {
			            _data = { limitMoney: result, usedType: 1 };
			          }
			          // 包时
			          if (that.showItem == 1 && that.form1.type == 2) {
			            _data = { limitMoney: result, usedType: 2 };
			          }
			          // 不限量个人
			          if (that.showItem == 1 && that.form1.type == 3) {
			            _data = { limitMoney: result, usedType: 3, poolType: 1 };
			          }
			          // 不限量企业
			          if (that.showItem == 1 && that.form1.type == 4) {
			            _data = { limitMoney: result, usedType: 3, poolType: 2 };
			          }
			          // 转发按并发
			          if (that.showItem == 8) {
			            _data = { limitMoney: result, usedType: 8 };
			          }
			          // 转发按量
			          if (that.showItem == 4) {
			            _data = { limitMoney: result, usedType: 4 };
			          }
			          // 虚拟
			          if (that.showItem == 11) {
			            _data = { limitMoney: result, usedType: 11 };
			          }
			          // 长效24
			          if (that.showItem == 7) {
			            _data = { limitMoney: result, usedType: 7 };
			          }
			          // 全局
			          if (that.showItem == 12) {
			            _data = { limitMoney: result, usedType: 12 };
			          }
			          // 全局
			          if (that.showItem == 14) {
			            _data = { limitMoney: result, usedType: 14 };
			          }
			          if (that.showItem == 15) {
			            _data = { limitMoney: result, usedType: 15 };
			          }
			          that.$store
			            .dispatch("ListUseableCoupon",_data)
						.then((response) => {
							if(response.data.code==0){
								let tarr = response.data.obj;
								if (tarr.length > 0) {
								  let arr = [{ label: "不使用优惠", value: 0 }];
								  tarr.forEach((item) => {
									  let time=that.formatDate2(item.endTime, 2)
								    let obj = {
								      label: item.money + "元(截止" + time + ")",
								      value: item.id,
									  price:item.money
								    };
								    arr.push(obj);
								  });
								  if(that.payType==3){
									 arr = [{ label: "不使用优惠", value: 0 }];
								  }
								  that.couponList = arr;
								}
							}
			          });
			        })
			        .catch(function (error) {
			          // error==上面的error
			        });					
			    },
				inputN(type,num1){
					let that=this
					if(that.dayvalue>29){
						that.dayvalue=29
						return false;
					}
				},
				add(type,num1,num2){
					let that=this
					if(type==1){
						if(that.multiple1<num2){
							that.multiple1=this.multiple1+num1
						}else{
							that.multiple1=num2
						}
					}else if(type==2){
						if(that.multiple2<num2){
							that.multiple2=this.multiple2+num1
						}else{
							that.multiple2=num2
						}
					}else if(type==3){
						if(that.multiple3<num2){
							that.multiple3=this.multiple3+num1
						}else{
							that.multiple3=num2
						}		
					}else if(type==4){
						if(that.multiple4<num2){
							that.multiple4=this.multiple4+num1
						}else{
							that.multiple4=num2
						}		
					}else if(type==15){
						if(that.multiple15<num2){
							that.multiple15=this.multiple15+num1
						}else{
							that.multiple15=num2
						}		
					}else if(type==13){
						if(that.dayvalue<num2){
							that.dayvalue=this.dayvalue+num1
						}else{
							that.dayvalue=num2
						}		
					}
							
				},
				reduce(type,num1,num2){				
					if(type==1){
						if(this.multiple1>num1){
							this.multiple1=this.multiple1-num1
						}else{
							this.multiple1=num1
						}	
					}else if(type==2){
						if(this.multiple2>num1){
							this.multiple2=this.multiple2-num1
						}else{
							this.multiple2=num1
						}	
					}else if(type==3){
						if(this.multiple3>num1){
							this.multiple3=this.multiple3-num1
						}else{
							this.multiple3=num1
						}	
					}else if(type==4){
						if(this.multiple4>num1){
							this.multiple4=this.multiple4-num1
						}else{
							this.multiple4=num1
						}	
					}else if(type==15){
						if(this.multiple15>num1){
							this.multiple15=this.multiple15-num1
						}else{
							this.multiple15=num1
						}	
					}else if(type==13){
						if(this.dayvalue>num1){
							this.dayvalue=this.dayvalue-num1
						}else{
							this.dayvalue=num1
						}	
					}		
				},
				submit2() {
				  let obj;
				  // 按量
				  if (this.order.type == 1) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: 0,
				      times: parseInt(this.multiple1 / 1000),
				    };
				  }
				  // 包时
				  if (this.order.type == 2) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: this.day,
				      times: 0,
				    };
				  }
				  // 不限量
				  if (this.order.type == 3) {
				    if (this.day == 1) {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.dayvalue,
				        times: 0,
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.day,
				        times: 0,
				      };
				    }
				  }
				  // 转发
				  if (this.order.type == 4) {
				    obj = {
				      tradeType: 2,
				      day: 0,
				      orderNo: this.order.orderNo,
				      times: parseInt(this.multiple2 / 100000),
				    };
				  }
				  // 独享
				  if (this.order.type == 5) {
				    if (this.day == 1) {
				      obj = {
				        tradeType: 2,
				        day: this.dayvalue,
				        orderNo: this.order.orderNo,
				        times: 0,
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        day: this.day,
				        orderNo: this.order.orderNo,
				        times: 0,
				      };
				    }
				  }
				  // 转发按并发
				  if (this.order.type == 8) {
				    obj = {
				      tradeType: 2,
				      day: this.day,
				      orderNo: this.order.orderNo,
				      times: 0,
				    };
				  }
				  // 转发按量
				  if (this.order.type == 9) {
				    obj = {
				      tradeType: 2,
				      day: this.day,
				      orderNo: this.order.orderNo,
				      times: 0,
				    };
				  }
				  //虚拟IP
				  if (this.order.type == 11) {
				    if (this.hoursM == 2) {
				      obj = {
				        tradeType: 2,
				        day: 0,
				        orderNo: this.order.orderNo,
				        times: parseInt(this.multiple4 / 100),
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        day: 0,
				        orderNo: this.order.orderNo,
				        times: parseInt(this.multiple3 / 100),
				      };
				    }
				  }
				  // 长效ip
				  if (this.order.type == 7) {
				    if (this.day == 1) {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.dayvalue,
				        times: 0,
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.day,
				        times: 0,
				      };
				    }
				  }
				  // 全局ip
				  if (this.order.type == 12) {
				    if (this.day == 1) {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.dayvalue,
				        times: 0,
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.day,
				        times: 0,
				      };
				    }
				  }
				  // 加速器ip
				  if (this.order.type == 14) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: this.day14,
				      times: 0,
				    };
				  }
				  if (this.order.type == 6) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: this.day,
				      times: 0,
				    };
				  }
				  				  
				  if (
				    (this.order.type == 15 && this.order.poolType == 1) ||
				    (this.order.type == 15 && this.order.poolType == 2) ||
				    (this.order.type == 15 && this.order.poolType == 3)
				  ) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: 0,
				      times: parseInt(this.multiple1 / 1000),
				    };
				  }
				  if (
				    (this.order.type == 15 && this.order.poolType == 4) ||
				    (this.order.type == 15 && this.order.poolType == 5) ||
				    (this.order.type == 15 && this.order.poolType == 6)
				  ) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: 0,
				      times: parseInt(this.multiple15 / 100),
				    };
				  }
				  let that = this;      
				  that.$store
				  		.dispatch("BuildTrade",obj)
				  		.then((response) => {
							console.log(that.money);
							if (that.payType == "6"&&that.money!=0) {
								// #ifdef MP-WEIXIN
								that.wxpay(response.data.obj)
								// #endif
								// #ifdef  MP-ALIPAY
								// #endif 
							}
							if (that.payType == "5"&&that.money!=0) {
								// #ifdef  MP-ALIPAY
								that.AliPay(response.data.obj)
								// #endif 
							}
							if(that.money==0){
								// #ifdef MP-WEIXIN
								that.payType=2
								// #endif
								// #ifdef  MP-ALIPAY
								that.payType=1
								// #endif 
								let tar={
								          payWay: that.payType,
								          chargeNo: response.data.obj,
								          couponId: that.coupon,
								        }
								that.$store
									.dispatch("TradeBuy",tar)
									.then((response) => {
										if(response.data.code==0){
											uni.navigateTo({
												url: "/pagesA/user/orderList"
											})
											uni.showToast({
												title:"订单购买成功"
											})
										}else{
											that.$store.commit("SET_ERRORINFORMATION", {
											  mes: response.data.msg,
											  icon: "error",
											});
										}
										  
									})
							}
				  			if (response.data.code == "0"&&that.payType == "3") {
								let tar =this.coupon == "0"? { payWay: that.payType, chargeNo: response.data.obj }
								      : {
								          payWay: that.payType,
								          chargeNo: response.data.obj,
								          couponId: that.coupon,
								        };
								that.$store
									.dispatch("TradeBuy",tar)
									.then((response) => {
										if(response.data.code==0){
											// 钱包
											if (that.payType == "3") {
												setTimeout(function() {
													uni.showToast({
														title:"支付成功",
													})
												}, 1000);											
												uni.navigateTo({
													url: "/pagesA/user/orderList"
												})
											}    
										}else{
											that.$store.commit("SET_ERRORINFORMATION", {
											  mes: response.data.msg,
											  icon: "error",
											});
										}
										  
									})
				  			}
								
				  		})			
				},
				submit3() {
					console.log(222)
				  let obj;
				  // 按量
				  if (this.order.type == 1) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: 0,
				      times: parseInt(this.multiple1 / 1000),
				    };
				  }
				  // 包时
				  if (this.order.type == 2) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: this.day,
				      times: 0,
				    };
				  }
				  // 不限量
				  if (this.order.type == 3) {
				    if (this.day == 1) {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.dayvalue,
				        times: 0,
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.day,
				        times: 0,
				      };
				    }
				  }
				  // 转发
				  if (this.order.type == 4) {
				    obj = {
				      tradeType: 2,
				      day: 0,
				      orderNo: this.order.orderNo,
				      times: parseInt(this.multiple2 / 100000),
				    };
				  }
				  // 独享
				  if (this.order.type == 5) {
				    if (this.day == 1) {
				      obj = {
				        tradeType: 2,
				        day: this.dayvalue,
				        orderNo: this.order.orderNo,
				        times: 0,
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        day: this.day,
				        orderNo: this.order.orderNo,
				        times: 0,
				      };
				    }
				  }
				  // 转发按并发
				  if (this.order.type == 8) {
				    obj = {
				      tradeType: 2,
				      day: this.day,
				      orderNo: this.order.orderNo,
				      times: 0,
				    };
				  }
				  // 转发按量
				  if (this.order.type == 9) {
				    obj = {
				      tradeType: 2,
				      day: this.day,
				      orderNo: this.order.orderNo,
				      times: 0,
				    };
				  }
				  //虚拟IP
				  if (this.order.type == 11) {
				    if (this.hoursM == 2) {
				      obj = {
				        tradeType: 2,
				        day: 0,
				        orderNo: this.order.orderNo,
				        times: parseInt(this.multiple4 / 100),
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        day: 0,
				        orderNo: this.order.orderNo,
				        times: parseInt(this.multiple3 / 100),
				      };
				    }
				  }
				  // 长效ip
				  if (this.order.type == 7) {
				    if (this.day == 1) {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.dayvalue,
				        times: 0,
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.day,
				        times: 0,
				      };
				    }
				  }
				  // 全局ip
				  if (this.order.type == 12) {
				    if (this.day == 1) {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.dayvalue,
				        times: 0,
				      };
				    } else {
				      obj = {
				        tradeType: 2,
				        orderNo: this.order.orderNo,
				        day: this.day,
				        times: 0,
				      };
				    }
				  }
				  // 加速器ip
				  if (this.order.type == 14) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: this.day14,
				      times: 0,
				    };
				  }
				  if (this.order.type == 6) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: this.day,
				      times: 0,
				    };
				  }
				  				  
				  if (
				    (this.order.type == 15 && this.order.poolType == 1) ||
				    (this.order.type == 15 && this.order.poolType == 2) ||
				    (this.order.type == 15 && this.order.poolType == 3)
				  ) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: 0,
				      times: parseInt(this.multiple1 / 1000),
				    };
				  }
				  if (
				    (this.order.type == 15 && this.order.poolType == 4) ||
				    (this.order.type == 15 && this.order.poolType == 5) ||
				    (this.order.type == 15 && this.order.poolType == 6)
				  ) {
				    obj = {
				      tradeType: 2,
				      orderNo: this.order.orderNo,
				      day: 0,
				      times: parseInt(this.multiple15 / 100),
				    };
				  }
				  let that = this;      
				  that.$store
				  		.dispatch("BuildTrade",obj)
				  		.then((response) => {
							if(response.data.code==0){
								that.baiduwx(response.data.obj)
							}	
				  		})			
				},
				baiduwx(data){
					let that=this
					let orderD=data
					// let orderD='Br/XotTRG3oeGm70yOpYPNf9gFPyA0eOqTK4aQdotio0X63oWR5kAqVidOaWOSgqhOikkPFVnjYq8vgkrQFGe8vofcOCq9hMyKosSB24QXlgz3EG8GjmPsaPawaFE23zrVQg40tVW9rafb/oEQzfrtjqGRBJB8QECQj8+mh1Z99qUsZT0TZZMEiR0paBtn6zJVsVg/4fgagcOOoWWh2G9gMh467fKXYXTjAED+MvzJt7UHlfs7U+D3Ixz8kxeiTkwfxQVhxA+NgncKwmk2AecqSzM6uAnZciay4bE22cJ0UxBJROk7J56yDvyjtpal84Z7semXgZobSZV6hJ07d+Pw=='
					that.openid=uni.getStorageSync("wxId").id
					let  activeMoney=that.activeMoney*100 
					this.$store
					.dispatch("BaidupaySign",{chargeNo:orderD})
					.then((response) => {
						if(response.data.code==0){
							
							that.rsaSign=response.data.obj
							that.nextPay(orderD)
						}	
					  })
					  .catch(() => {});	 
				},
				nextPay(e) {
					let that=this
					let  activeMoney=that.money*100
					let dtr={
						appKey:"MMU2KF",
						dealId:2566984488,
						tpOrderId:e,
						totalAmount:activeMoney,
						notifyUrl:'https://vips.xiongmaodaili.com/xiongmao-web/trade/baiduNotify',
						dealTitle:'熊猫代理',
						signFieldsRange:1,
						rsaSign:this.rsaSign
					}
				    swan.requestPolymerPayment({
				        orderInfo: dtr,
				        success: res => {
				            swan.showToast({
				                title: '支付成功',
				                icon: 'success'
				            });
				            console.log('success', res);
				        },
				        fail: err => {
				            swan.showToast({
				                title: err.errMsg,
				                icon: 'none'
				            });
				            console.log('fail', err);
				        }
				    });    
				},
				getisSuccess(data){
					let that=this
					let obj={
						chargeNo:data
					}
					that.$store
						.dispatch("IsSuccess",obj)
						.then((response) => {
						})
				},
				AliPay(data){
					let that=this
					let orderD=data
					let  activeMoney=that.money*100
					console.log(activeMoney,data,uni.getStorageSync("alipayId"));
					uniCloud.callFunction({
					    name: 'user-common2',
						data:{
							totalFee: activeMoney, 
							outTradeNo:data,
							openid:uni.getStorageSync("alipayId").id,
							subject:'熊猫代理'
						},				
					    success(res) {		
							console.log("成功1233",res.result.orderInfo);
							uni.requestPayment({
								orderInfo: res.result.orderInfo,
								success(){
									that.getisSuccess(orderD)
								},
								fail(){
									that.getisSuccess(orderD)
								}																							 																																 
							})			   
					    },
						fail(){
							that.getisSuccess(orderD)
						}
					})	
				},
				wxpay(data){
					let that=this
					let orderD=data
				   that.openid=uni.getStorageSync("wxId").id
				   let  activeMoney=that.money*100
				   uniCloud.callFunction({
				       name: 'user-common',
						data:{
							totalFee: activeMoney, 
							outTradeNo:data,
							openid:that.openid,
							subject:''
						},
				       success(res) {
						   uni.requestPayment({
							   ...res.result.orderInfo,
								success(){
									that.getisSuccess(orderD)
								},
								fail(){
									that.getisSuccess(orderD)
								}
						   })
				       },
					   fail(){
						  that.getisSuccess(orderD)
					   }
				   })
				},
		}
	}
</script>

<style lang="less">
#orderPay{
	width: 94%;
	margin: 0 auto;
	.block{
		display: inline-block;
		height: 48rpx;
		line-height: 48rpx;			
		overflow: hidden;
		// padding: 0 10rpx;
		input{
			display: inline-block;
			width: 160rpx;
			height: 48rpx;
			line-height: 48rpx;
			text-align: center;
		}
	}
	.add,.reduce{
		padding: 2rpx 14rpx;
		color: #666;
		background-color: #F1F3F4;
	}
	.item{
		margin: 16rpx 0;
		.easy-select{
			border: none;
			display: inline-block;
			text-align: left;
			font-size: 24rpx !important;
			position: relative;
			top: 24rpx;
			input{
				font-size: 24rpx !important;
			}
		}
	}
	.block{
		display: inline-block;
		height: 48rpx;
		line-height: 48rpx;			
		overflow: hidden;
		padding: 0 10rpx;
		input{
			display: inline-block;
			width: 160rpx;
			height: 48rpx;
			line-height: 48rpx;
			text-align: center;
		}
	}
	.iblock{
		width: 450rpx;
		margin-left: 20rpx;
		margin-top: 10rpx;
		text-align: right;
		display: inline-block;
	}
	.title{
		display: inline-block;
		width: 200rpx;
		font-size: 28rpx;
	}
	.part2{
		margin-top: 20rpx;
	}
	.active{
		padding-left: 24rpx;
		height: 100rpx;
		line-height: 100rpx;
		text{
			display: inline-block;
			width: 460rpx;
		}
		input{
			display: inline-block;
			// color: #FFFFFF;
		}
		.im{
			display: inline-block;
		}
		image{
			width: 30rpx;
			height: 30rpx;
			margin-right: 10rpx;
			position: relative;
			top: 5rpx;
		}	
	}
	.prompt_text2{
	    color:rgb(72, 110, 245);
	    font-size: 26rpx;
	}
	.btn{
		margin-top: 50rpx;
		button{
			border: none;
			width: 80%;
			border-radius: 70rpx;
			background: #007AFF;
		}
	}
}
</style>
